package com.whu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whu.aircraft.User;
import com.whu.dao.interfaces.UserDao;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    final UserDao userDao;
    public UserService(UserDao userDao){
        this.userDao = userDao;
    }
    public IPage<User> listWithPage(int page, int num){
        Page<User> pager = new Page<>(page,num);
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        IPage<User> iPage = userDao.selectPage(pager,queryWrapper);
        return iPage;
    }
    public List<User> list(){
        return userDao.selectList(new QueryWrapper<User>());
    }
    public void create(User user){
        userDao.insert(user);
    }
    public void delete(Long id){
        userDao.deleteById(id);
    }
    public void update(User user){
        userDao.updateById(user);
    }
}
